package com.local.web.constants;

/**
 * 首页商品配置的类型
 */
public enum IndexConfigTypeEnum {

    DEFAULT(0, "DEFAULT"), //默认类型
    INDEX_SEARCH_HOTS(1, "INDEX_SEARCH_HOTS"), //热门搜索配置
    INDEX_SEARCH_DOWN_HOTS(2, "INDEX_SEARCH_DOWN_HOTS"), //
    INDEX_GOODS_HOT(3, "INDEX_GOODS_HOTS"), //热销商品配置
    INDEX_GOODS_NEW(4, "INDEX_GOODS_NEW"), //新品上线配置
    INDEX_GOODS_RECOMMOND(5, "INDEX_GOODS_RECOMMOND"); //为您推荐配置

    private Integer type;
    private String name;

    IndexConfigTypeEnum(Integer type, String name) {
        this.type = type;
        this.name = name;
    }

    /**
     * 根据 type 查询对应的类型数据
     * @param type
     * @return
     */
    public static IndexConfigTypeEnum getIndexConfigTypeEnumByType(Integer type) {
        for (IndexConfigTypeEnum indexConfigTypeEnum : IndexConfigTypeEnum.values()) {
            if (indexConfigTypeEnum.getType() == type) {
                return indexConfigTypeEnum;
            }
        }
        return DEFAULT;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
